package br.com.skytef.print;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.util.List;

public class PrintLayout implements Printable {
	private PrintPage txtPage;
	
	public PrintLayout(PrintPage page){
		this.txtPage = page; 
	}
	
  public int print(Graphics g, PageFormat pf, int pageIndex) {
    if (pageIndex != 0)
      return NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D) g;
    g2.setFont(new Font("Arial", Font.PLAIN, 10));
    g2.setPaint(Color.black);
    
    int indice = 30;
    for (PrintLine line : txtPage.getLines()) {
    	indice = indice + 10;
    	Font font = line.getFont();
    	g2.setFont(font);
    	g2.drawString(line.getLine(), 1, indice);	
	}
    return PAGE_EXISTS;
  }
}